<template>
	<div class="content">
		<second-nav :tid="Parent_tid" v-on:cur="cur"></second-nav>
		<div class="mar-top"></div>
		<div v-if="add">
			<compon v-for="(item,index) in tuilist" :key="index" :ky="index" :tuid="item" :navs="navtid" ></compon>
		</div>
		<div v-else>
			<div class="clearfix" >
				<comm v-for="(el,index) in badlist" :key="index" :record="el"></comm>
			</div>
			<div class="botton" v-if="addbot">
				点击加载更多
			</div>
		</div>
	</div>
</template>

<script>
	import CONFIG from "@/config";
	let partionList=CONFIG.partitionList;
	import axios from 'axios';
	import column from './column'
	import secondNav from './secondNav'
	import compon from './compon'
	import comm from './comm'
	export default {
		name:"channel",
	 	data(){
			return{
				Parent_tid: this.$route.params.id,
				dataArr:[],
				navtid:"1",
				tuilist:[],
				badlist:[],
				addbot:false,
				add:false
			}
		},
		components: {
			secondNav,
			compon,
			comm
		},
		created(){
			this.$emit("navs","1")
			this.tui(this.$route.params.id)
		},
		mounted(){
			
		},
		watch: {
			$route(newValue,oldValue) {
				this.addbot=false
				this.Parent_tid = newValue.params.id
				this.tui(newValue.params.id)
			},
		},
		methods:{
			tui(lisId){
				this.add=false
				this.tuilist=[]
				this.badlist=[]
				let s=this
				partionList["0"].forEach((el) => {
					if(lisId==el.tid){
						s.tuilist.push(el.tid)
						partionList[el.tid].forEach((el) => {
							s.tuilist.push(el.tid)
						})
						s.badlist=[]
						s.add=true
//						console.log(s.tuilist)
						return
					}
				})
				if(!this.add){
					this.tuilist=[]
					var url = CONFIG.domain + "?rid="+lisId
					axios.get(url).then((res) => {
						this.badlist=res.data.data.splice(0,10)
						this.addbot=true
					})
					
				}
				
			},
			cur(id){
				this.$emit("navs",id)
				this.navtid=id
			},
//			_getNews(ved){
//				var url = CONFIG.domain + "?rid="+ved
//				axios.get(url).then((res) => {
//					this.dataArr=res.data.data.list
//				}).then(()=>{
//				})
//	 		},
 		}
	}
</script>

<style lang="scss">
	.content{
		position: relative;
		.mar-top{
			height: 38px;
			border-bottom: 1px solid #ccc;
			margin-bottom: 10px;
		}
	}
	.botton{
		margin-top: 10px;
		text-align: center;
		font-size: 12px;
		background-color: #e7e7e7;
		height: 30px;
		line-height: 32px;
		color: #fb7299;
	}
</style>